package com.example.emptytest.Fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import com.example.emptytest.R;
import com.example.emptytest.TabFragment.TabFragment1;
import com.example.emptytest.Adapter.TabFragmentAdapter1;
import com.google.android.material.tabs.TabLayout;

import java.util.ArrayList;
import java.util.List;

public class Fragment_1 extends Fragment implements View.OnClickListener {
    private ViewPager pager;
    private TabFragmentAdapter1 tabFragmentAdapter;
    private List<TabFragment1> fragmentList;
    private TabLayout tabLayout;
    private TabFragment1 fragment1,fragment2,fragment3,fragment4,fragment5;
    private List<String> mTitles;
    private String [] title={"社团信息","成员列表","社团活动","活动审核","公告"};



    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_1,container,false);

        pager = view.findViewById(R.id.page_1);
        tabLayout = view.findViewById(R.id.tab_layout_1);



        return view;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

        fragmentList=new ArrayList<>();
        mTitles=new ArrayList<>();
        for(int i=0;i<title.length;i++){
            mTitles.add(title[i]);
            fragmentList.add(new TabFragment1(title[i]));
        }

        tabFragmentAdapter=new TabFragmentAdapter1(getChildFragmentManager(),fragmentList,mTitles);
        pager.setAdapter(tabFragmentAdapter);
        tabLayout.setupWithViewPager(pager);//与ViewPage建立关系



    }

    @Override
    public void onClick(View v) {

    }
}

